<template>
 <view class="main" @touchstart="touchStart" @touchend="touchEnd">
  <view class="pleft" @click="jumpindex">
	<image src="https://ppp.new.zeroitem.cn/ppp/pleft.png" class="limg"></image> 
  </view>
  <view class="part1">今日有{{my.onum}}单拍摄</view> 
  <view class="part2">
	  <image :src="my.avatar" class="img1"></image>
	  <view class="part2-1">
		<view class="txt1">{{my.nickname}}</view>  
		<view class="txt2">厦门</view>
	  </view>
  </view>
  <view class="part3 p1" @click="orderlog()">
	<image src="https://ppp.new.zeroitem.cn/ppp/my/4.png" class="img2"></image>
	 下单记录
  </view>
 <view class="part3 p2" @click="yxps()">
 	<image src="https://ppp.new.zeroitem.cn/ppp/my/4.png" class="img2"></image>
 	 优选拍手
 </view> 

 <view class="part3 p2" @click="wallect()">
 	<image src="https://ppp.new.zeroitem.cn/ppp/my/2.png" class="img2"></image>
 	 钱包
 </view> 
  
 <view class="part3 p2" @click="fxshare()">
 	<image src="https://ppp.new.zeroitem.cn/ppp/my/5.png" class="img2"></image>
 	 我的分享
 </view>  
 <button class="part3 p2" open-type="contact">
 	<image src="https://ppp.new.zeroitem.cn/ppp/my/3.png" class="img2"></image>
 	 联系客服
 </button>   
  <view class="part3 p2" @click="set1">
  	<image src="https://ppp.new.zeroitem.cn/ppp/my/6.png" class="img2"></image>
  	 设置
  </view> 
  <view class="part4" @click="zhpk">
	转换为拍客  
  </view>
  <view class="part5"></view> 
  <view class="part6"></view>
  
  
   <view class="mask" v-if="showtc==1" style="z-index:200000">
      <view class="qtc">
		<view class="tctxt-2 txt6">是否切换为拍客</view> 
		<view class="tcbtn1 btnm">
		  <view class="tcbtn btn1" @click="closetc">否</view>
		  <view class="tcbtn btn2" @click="jumppk">是</view>
		</view>
	  </view>
   </view>
  
  
 </view>
</template>
<script>
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	import {
		toLogin
	} from '@/utils/login'
	
	import {
		loadingFun,
		menuJump
	} from '@/utils/tools'	
    import {
		mydetail,psdetail
	} from '@/api/ppp'	
	import {
		loadingType
	} from '@/utils/type'
		
	const app = getApp()
	export default {
	    data() {
	        return {
	         showtc:0,
			 startX:0,
			 my:[]
	        }
	    },
		onShow(){
	      this.getmydetail();
		},
	    methods: {
			fxshare(){
			 uni.navigateTo({
			 	url:"/pages/ppp/my/share"
			 })		
			},
			wallect(){
				uni.redirectTo({
					url:"/pages/user_wallet/user_wallet"
				})		
			},
			yxps(){
			  uni.redirectTo({
			  	url:"/pages/ppp/my/wdyx"
			  })		
			},
			set1(){
			 uni.redirectTo({
			 	url:"/pages/user_profile/user_profile"
			 })	
			},
			async getmydetail(){
			  var that=this;
			  const{code,msg,data,
			  }= await mydetail({});
			  if(code==1){
	           that.my=data;
			  }	
			},
           touchStart: function (e) {
			if (e.touches.length == 1) {
				//设置触摸起始点水平方向位置
				this.startX=e.touches[0].clientX;
			}
		  },
		/**
		 * 触摸结束
		 * @param {Object} e
		 */
		touchEnd: function (e) {
			if (e.changedTouches.length == 1) {
				//手指移动结束后水平位置
				var endX = e.changedTouches[0].clientX;
				let diff = endX-this.startX;
				if(Math.abs(diff)>20){
					if(diff>0){
					  uni.redirectTo({
					  	url:"/pages/ppp/index/order"
					  })
					}else{
					 uni.redirectTo({
					 	url:"/pages/ppp/index/order"
					 })
					}
				}
			}
		
		},	
		jumpindex(){
		 uni.redirectTo({
		 	url:"/pages/ppp/index/order"
		 })	
		},
		 zhpk(){
			this.showtc=1;
		 },
		 closetc(){this.showtc=0;},
		 orderlog(){
		  uni.redirectTo({
		  	url:"/pages/ppp/index/dqdd"
		  })	 
		 },
		 
		 async jumppk(){
		  this.showtc=0;
		  const{
		     data
		   }= await psdetail({});
		  if(data.flag==2){
			var dtype=data.bd.result.addressComponent.city+"."+data.bd.result.addressComponent.district;
			uni.navigateTo({
				url:"/pages/ppp/ps1/dqzz?dtype="+dtype
			})   
		  }else{
			uni.navigateTo({
				url:"/pages/ppp/ps/psrz"
			})   
		  }
		 } 
	    },
		computed: {
			...mapGetters(['isLogin']),
		}
	}
</script>


<style>
@import "./index.css";	
</style>
